package org.usmile.algorithms.huawei.acm;

import java.util.Arrays;
import java.util.Scanner;

// https://fcqian.blog.csdn.net/article/details/127914382
public class _日志限流 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] records = new int[n];
        int maxLimit = 0;
        int total = 0;
        for (int i = 0; i < n; i++) {
            int record = sc.nextInt();
            records[i] = record;
            maxLimit = Math.max(maxLimit, record);
            total += record;
        }

        int totalLimit = sc.nextInt();
        if (totalLimit >= total) {
            System.out.println(-1);
            return;
        }

        int minLimit = total / n;
        int ans = minLimit;
        while (maxLimit - minLimit > 1) {
            int limit = (maxLimit + minLimit) / 2;
            int tempTotal = 0;
            for (int record : records) {
                tempTotal += Math.min(record, limit);
            }

            if (tempTotal > totalLimit) {
                maxLimit = limit;
            } else if (tempTotal < totalLimit) {
                minLimit = limit;
                ans = limit;
            } else {
                System.out.println(limit);
                return;
            }
        }
        System.out.println(ans);
    }
}
